package mts.utils;

@Deprecated
public class MessageUtil {

	@Deprecated
	public static byte shortToUnsignedByte(short value) {
		if (value < 0 || value > 255) {
			throw new IllegalArgumentException("Value must be in the range 0-255, but it was " + value);
		}
		
		return (byte)(value & 0xff);
	}
	
	@Deprecated
	public static short unsignedByteToShort(byte value) {
		return (short) (value & 0xff);
	}
	
	@Deprecated
	public static byte[] shortToUnsignedByteArray(short[] array, int start, int end) {
		byte[] ret = new byte[array.length];
		for (int i = start; i < end; i++) {
			ret[i - start] = shortToUnsignedByte(array[i]);
		}
		
		return ret;
		
	}
	
	@Deprecated
	public static short[] unsignedByteArrayToShortArray(byte[] array, int start, int end) {
		short[] ret = new short[array.length];
		for (int i = start; i < end; i++) {
			ret[i - start] = unsignedByteToShort(array[i]);
		}
		
		return ret;
		
	}
	
	private MessageUtil() {}
}
